package kr.hkit.info.powerjava.ch23;

public class MyCountThread extends Thread {

	private Counter sharedCounter;

	public MyCountThread(Counter sharedCounter) {
		this.sharedCounter = sharedCounter;
	}
	
	public void run(){
		int i =0;
		while(i<20000){
			sharedCounter.increment();
			sharedCounter.decrement();
			
			if(i%40==0)sharedCounter.printCounter();
			try {
				sleep((int)(Math.random()*2));
			} catch (Exception e) {
				// TODO: handle exception
			}
			
		}
	}
}
